{extend name="public:layout" /}
{block name="title"}结算单列表{/block}
{block name="head"}
<style>
    .leave_layer p {height: 40px;line-height: 40px;}
</style>
{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <ol class="breadcrumb">
                    <li class="active"><i class="fa fa-hand-o-right"></i> 结算单列表</li>
                </ol>
            </ol>
            <div class="clearfix"></div>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <form class="form-inline" id="searchForm" method="post">
                    <div class="form-group">
                        <div class="input-group">
                            <select id="car_status" class="form-control" onchange="refresh();">
                                <option value="2,3">全部</option>
                                <option value="2" selected>待结算</option>
                                <option value="3">已结算</option>
                            </select>
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="请输入车牌号" name="car_sn" />
                        </div>
                    </div>
                    <div class="form-group">
                        <div class="input-group">
                            <input class="form-control" type="text" placeholder="请输入司机姓名" name="fleet_driver" />
                        </div>
                    </div>
                    <button type="button" class="btn btn-info" onclick="refresh()"><i class="fa fa-search"></i> 搜索</button>
                    <a class="btn btn-white" href="{:url('index',['mid'=>$Request.param.mid])}">
                        <i class="fa fa-trash"></i> 清空
                    </a>
                </form>
            </div>
            <table class="table table-bordered" id="grid"></table>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    $(function () {
        //列定义
        var columnsData=[
            {field: 'state', checkbox:true,},
            {field: 'aid', title: '订单',width:60,sortable:true},
            {field: 'car_sn', title: '车辆',formatter:function (value,row,index) {
                    var html='';
                    if(row.btype_aid==1){
                        html='<span class="label label-success" style="display:block;font-size:18px;padding:10px 8px;margin:5px;font-weight:500;">'+row.car_sn+'</span>';
                    }else{
                        html='<span class="label label-warning" style="display:block;font-size:18px;padding:10px 8px;margin:5px;font-weight:500;">'+row.car_sn+'</span>';
                    }
                    return html;
                }
            },
            {field: 'title', title: '行程单',formatter:function (value,row,index) {
                    if(row.order_delay>0){
                        return row.title+'('+row.order_odd+')'+' <span class="label label-danger">延期'+row.order_delay+'天</span>';
                    }
                    return row.title+'('+row.order_odd+')';
                }},
            {field: 'out_time', title: '出车时间',sortable:true},
            {field: 'back_time', title: '收车时间',sortable:true},
            {field: 'fleet_driver', title: '驾驶员'},
            {field: 'reckoner', title: '操作员'},
            {field: 'operate', title: '操作', align: 'center',
                formatter:function (value,row,index) {
                    var html='';
                    if(row.car_status==2 || row.btype_aid>1){ //收车或外借车辆才可以填写结算单
                        html+='<a href="__URL__/edit.html?aid='+row.aid+'&mid='+row.mid+'&tpl=edit_account" class="btn btn-success btn-xs">结算</a> ';
                    }
                    html+='<a href="__URL__/edit.html?aid='+row.aid+'&mid='+row.mid+'&tpl=car_send" class="btn btn-warning btn-xs">打印结算单</a> ';
                    return html;
                }
            }
        ];
        In('btable', function () {
            $('#grid').bootstrapTable({
                showColumns:true,
                url: '__URL__/pagelist.html?mid={$Request.param.mid}',
                toolbar:'#buttons',
                sortName:'car_status',
                sortOrder:'asc',
                method:'post',
                pagination:true,
                queryParamsType:'page',
                sidePagination:'server',
                pageSize:60, //每页记录数
                showRefresh:true, //显示刷新按钮
                showToggle:true, //显示切换视图按钮
                showPaginationSwitch:true, //显示数据条数选择框
                idField:'aid', //主键列
                clickToSelect:true, //设置true 将在点击行时，自动选择rediobox 和 checkbox
                singleSelect:false, //设置true 将禁止多选
                maintainSelected:true, //设置为true 将记住选择项
                queryParams:function (params) {
                    params.op="{$Request.param.op}";
                    params.car_sn=$("input[name='car_sn']").val();
                    params.car_status=$('#car_status').val();
                    params.fleet_driver=$("input[name='fleet_driver']").val();
                    return params;
                },
                columns: columnsData
            });
        });
    });
    //刷新表格
    function refresh() {
        $('#grid').bootstrapTable('refresh');
    }
</script>
{/block}